package me.zyl.tools;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PaintFlagsDrawFilter;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;

import java.util.Calendar;
import java.util.TimeZone;

public class CommonUtils
{
  private static CommonUtils mCommonUtils;
  private int HOURS = 0;
  private int MILLS = 0;
  private int MINUTES = 0;
  private int SECONDS = 0;
  private DisplayMetrics dm;
  private boolean isLight = true;
  private Calendar mCalendar;
  private Context mContext;
  Handler mHandler = new Handler();
  private PaintFlagsDrawFilter mPDrawFilter = new PaintFlagsDrawFilter(0, 3);
  Runnable mRunnable = new Runnable()
  {
    public void run()
    {
      Log.i("zyltest","CommonUtils.run..."+CommonUtils.this.isLight);
//      CommonUtils localCommonUtils = CommonUtils.this;
//      if (CommonUtils.this.isLight) {}
//      for (boolean bool = false;; bool = true)
//      {
//        localCommonUtils.isLight = bool;
//        CommonUtils.this.mHandler.postDelayed(CommonUtils.this.mRunnable, 10000L);
//        return;
//      }
    }
  };
  
  private CommonUtils(Context paramContext)
  {
    this.mContext = paramContext;
    this.dm = this.mContext.getResources().getDisplayMetrics();
    setTimeToNow();
    this.mHandler.postDelayed(this.mRunnable, 10000L);
  }
  
  public static CommonUtils getInstance(Context paramContext)
  {
    if (mCommonUtils == null) {
      mCommonUtils = new CommonUtils(paramContext);
    }
    return mCommonUtils;
  }
  
  public int dip2px(float paramFloat)
  {
    return (int)(getScreenDensity() * paramFloat + 0.5F);
  }
  
  public int getDate()
  {
    return this.mCalendar.get(Calendar.DAY_OF_MONTH);
  }
  
  public String getDateStr()
  {
    int i = getDate();
    if (i < 10) {}
//    for (String str = "0" + i;; str = i) {
//      return str + " " + mCommonUtils.getMonthName().toUpperCase() + " " + mCommonUtils.getDayNameOfWeek().toUpperCase();
//    }
    return "20110505";
  }
  
  public String getDateofString()
  {
    if (this.mCalendar.get(Calendar.DAY_OF_MONTH) < 10) {
      return "0" + this.mCalendar.get(Calendar.DAY_OF_MONTH);
    }
    return this.mCalendar.get(Calendar.DAY_OF_MONTH)+"";
  }

  public String getDayOfMonth(){
      return this.mCalendar.get(Calendar.DAY_OF_MONTH)+"";
  }

  public String getDayNameOfWeek()
  {
    switch (getDayOfWeek())
    {
    default: 
      return "";
    case 1: 
      return "日";
    case 2: 
      return "一";
    case 3: 
      return "二";
    case 4: 
      return "三";
    case 5: 
      return "四";
    case 6: 
      return "五";
    case 7:
      return "六";
    }
//    return "Sat";
  }
  public String getDayNameOfWeekEn()
  {
    switch (getDayOfWeek())
    {
      default:
        return "";
      case 1:
        return "SUN";
      case 2:
        return "MON";
      case 3:
        return "TUE";
      case 4:
        return "WED";
      case 5:
        return "THU";
      case 6:
        return "FRI";
      case 7:
        return "SAT";
    }
//    return "Sat";
  }

  public String getDayNameOfWeekNo()
  {
    switch (getDayOfWeek())
    {
      default:
        return "";
      case 1:
        return "7";
      case 2:
        return "1";
      case 3:
        return "2";
      case 4:
        return "3";
      case 5:
        return "4";
      case 6:
        return "5";
      case 7:
        return "6";
    }
//    return "Sat";
  }
  
  public int getDayOfWeek()
  {
    return this.mCalendar.get(Calendar.DAY_OF_WEEK);
  }
  
  public float getHourAngle()
  {
    return (30.0F * (this.HOURS + this.MINUTES / 60.0F + this.SECONDS / 3600.0F) + 90.0F) % 360.0F;
  }
  
  public String getHourOfString()
  {
    if (this.HOURS < 10) {
      return "0" + this.HOURS;
    }
    return this.HOURS+"";
  }
  
  public float getHourSweepAngle()
  {
    return 360.0F * (this.HOURS + this.MINUTES / 60.0F + this.SECONDS / 3600.0F) / 12.0F;
  }

  public float getHour24SweepAngle()
  {
    return 360.0F * (this.HOURS + this.MINUTES / 60.0F + this.SECONDS / 3600.0F)/24.0F;
  }
  
  public float getHourWalkAngle()
  {
    return 360.0F * this.HOURS / 12.0F;
  }
  
  public int getHoursNow()
  {
    return this.HOURS;
  }
  
  public int getMillsNow()
  {
    return this.MILLS;
  }
  
  public float getMinuteAngle()
  {
    return ((this.MINUTES + this.SECONDS / 60.0F) * 360.0F / 60.0F + 90.0F) % 360.0F;
  }
  
  public float getMinuteSweepAngle()
  {
    return 360.0F * (this.MINUTES + this.SECONDS / 60.0F) / 60.0F;
  }
  
  public float getMinuteWalkAngle()
  {
    return 360.0F * this.MINUTES / 60.0F;
  }
  
  public int getMinutesNow()
  {
    return this.MINUTES;
  }
  
  public String getMinutesOfString()
  {
    if (this.MINUTES < 10) {
      return "0" + this.MINUTES;
    }
    return this.MINUTES+"";
  }
  
  public int getMonth()
  {
    return this.mCalendar.get(Calendar.MONTH);
  }

  //数字月份
  public String getMonthNo(){
    return getMonth()+1+"";
  }

  //中文月份
  public String getMonthChineseName()
  {
    switch (getMonth())
    {
    default: 
      return "";
    case 0: 
      return "一";
    case 1: 
      return "二";
    case 2: 
      return "三";
    case 3: 
      return "四";
    case 4: 
      return "五";
    case 5: 
      return "六";
    case 6: 
      return "七";
    case 7: 
      return "八";
    case 8: 
      return "九";
    case 9: 
      return "十";
    case 10: 
      return "十一";
    case 11:
      return "十二";
    }
  }

  //英文月份
  public String getMonthName()
  {
    switch (getMonth())
    {
    default: 
      return "";
    case 0: 
      return "Jan";
    case 1: 
      return "Feb";
    case 2: 
      return "Mar";
    case 3: 
      return "Apr";
    case 4: 
      return "May";
    case 5: 
      return "Jun";
    case 6: 
      return "Jul";
    case 7: 
      return "Aug";
    case 8: 
      return "Sep";
    case 9: 
      return "Oct";
    case 10: 
      return "Nov";
    case 11:
      return "Dec";
    }
  }
  
  public float getScreenDensity()
  {
    return this.dm.density;
  }
  
  public int getScreenHeight()
  {
    return this.dm.heightPixels;
  }
  
  public int getScreenWidth()
  {
    return this.dm.widthPixels;
  }
  
  public float getSecondAngle()
  {
    int i = this.SECONDS;
    int j = this.MILLS;
    return (i * 6.0F + j * 0.006F + 90.0F) % 360.0F;
  }
  
  public String getSecondOfString()
  {
    if (this.SECONDS < 10) {
      return "0" + this.SECONDS;
    }
    return this.SECONDS+"";
  }
  
  public float getSecondSweepAngle()
  {
    int i = this.SECONDS;
    int j = this.MILLS;
    return i * 6.0F + j * 0.006F;
  }
  
  public float getSecondWalkAngle()
  {
    return this.SECONDS * 360 / 60.0F;
  }
  
  public int getSecondsNow()
  {
    return this.SECONDS;
  }
  
  public String getTimeStr()
  {
    StringBuilder localStringBuilder;
    if (this.HOURS < 10)
    {
      String str = "0" + this.HOURS;
      localStringBuilder = new StringBuilder(String.valueOf(str)).append(":");
      if (this.MINUTES >= 10) {
//        break label106;
      }
    }
//    label106:
//    for (String str = "0" + this.MINUTES;; str = this.MINUTES)
//    {
//      return str;
//      str = this.HOURS;
//      break;
//    }
    return "zyl305";
  }
  
  public boolean isLight()
  {
    return this.isLight;
  }
  
  public int px2dip(float paramFloat)
  {
    return (int)(paramFloat / getScreenDensity() + 0.5F);
  }
  
  public void setCalendarToNow()
  {
    this.mCalendar = Calendar.getInstance();
    this.mCalendar.setTimeZone(TimeZone.getDefault());
  }
  
  public void setDrawFilter(Canvas paramCanvas)
  {
    paramCanvas.setDrawFilter(this.mPDrawFilter);
  }
  
  public void setTimeToNow()
  {
    setCalendarToNow();
    this.HOURS = this.mCalendar.get(Calendar.HOUR_OF_DAY);
    this.MINUTES = this.mCalendar.get(Calendar.MINUTE);
    this.SECONDS = this.mCalendar.get(Calendar.SECOND);
    this.MILLS = ((int)(this.mCalendar.getTimeInMillis() % 1000L));
  }
  
  public float sp2px(float paramFloat)
  {
    return this.mContext.getResources().getDisplayMetrics().scaledDensity * paramFloat;
  }
}


/* Location:              G:\zyl\ylwork\Android\Android_Decode\apk2java\apktool2.1.0\WatchFaceSports\classes-dex2jar.jar!\com\tencent\tws\watchfacelib\CommonUtils.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */